package com.gljx.web.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.gljx.web.Entity.Team;
import com.gljx.web.dao.CommonDao;
import com.gljx.web.dao.TeamMapper;
import com.gljx.web.service.TeamService;

@Transactional
@Service
public class TeamServiceImpl extends CommonDao implements TeamService{
	
	@Autowired
	private TeamMapper teamMapper;

	/**
	 * 实现根据公司id查询
	 */
	@Override
	public List<Team> queryTeamByFcontrolunitid(String companyId) {
		// TODO Auto-generated method stub
		return teamMapper.selectTeamByFcontrolunitid(companyId);
	}

	/**
	 * 实现根据公司id和名称查询
	 */
	@Override
	public List<Team> queryTeamByFcontrolunitidAndFnameL2(String companyId, String fnameL2) {
		// TODO Auto-generated method stub
		Map<String, String> map = new HashMap<>();
		map.put("companyId", companyId);
		map.put("fnameL2", fnameL2);
		return teamMapper.selectTeamByFcontrolunitidAndFnameL2(map);
	}

	/**
	 * 实现添加
	 */
	@Override
	public void addTeam(Team team) {
		// TODO Auto-generated method stub
		teamMapper.insertSelective(team);
	}

	/**
	 * 实现删除
	 */
	@Override
	public void deleteTeamByFid(String fid) {
		// TODO Auto-generated method stub
		teamMapper.deleteByPrimaryKey(fid);
	}

	/**
	 * 实现根据fid查询
	 */
	@Override
	public Team queryTeamByFid(String fid) {
		// TODO Auto-generated method stub
		return teamMapper.selectTeamByFid(fid);
	}

	/**
	 * 实现修改
	 */
	@Override
	public void modifyTeam(Team team) {
		// TODO Auto-generated method stub
		teamMapper.updateByPrimaryKeySelective(team);
	}

	@Override
    public List<Team> queryTeam(String companyId) {
        // TODO Auto-generated method stub
        return teamMapper.selTeam(companyId);
    }

	@Override
    public List<Team> queryTeamByName(String fnameL2, String companyId) {
        // TODO Auto-generated method stub
        Map<String, String> map = new HashMap<>();
        map.put("fnameL2", fnameL2);
        map.put("companyId", companyId);
        return teamMapper.selTeamByName(map);
    }
}
